"""
    @Author  ：思念 
    @File    ：4.绑定回调.py
    @Date    ：2025/3/18 15:05 
"""

import asyncio



def callback(future):
    print('回调内容为:', future.result())


async def text_work():
    print('开始执行')
    await asyncio.sleep(1)
    print('执行结束')
    return '返回内容'

async def main():
    tasks = [asyncio.create_task(text_work())]
    for task in tasks:
        task.add_done_callback(callback)
    await asyncio.gather(*tasks)

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())